package com.zhongke.cotrun.mapper;

import com.zhongke.cotrun.model.pojo.LevelOneComment;
import org.apache.ibatis.annotations.*;

import java.math.BigInteger;
import java.util.List;

public interface LevelOneCommentMapper {

    /**
     * 新增一级评论
     *
     * @param levelOneComment
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "levelOneCommentId", keyColumn = "level_one_comment_id")
    @Insert("INSERT INTO `level_one_comment` (`link_project_id`, `link_user_id`, `link_user_name`,`link_user_account_head`,`comment_content`, `create_time`, `state`,`type`) VALUES (#{linkProjectId}, #{linkUserId}, #{linkUserName},#{linkUserAccountHead},#{commentContent} ,NOW(), 0,#{type})")
    public boolean insertLevelOneComment(LevelOneComment levelOneComment);

    /**
     * 修改评论状态
     *
     * @param state
     * @param levelOneCommentId
     * @return
     */
    @Update("UPDATE `level_one_comment` SET `state`=#{state} WHERE (`level_one_comment_id`=#{levelOneCommentId})")
    public Boolean updateStateForLevelOneComment(@Param("state") Integer state, @Param("levelOneCommentId") Integer levelOneCommentId);

    /**
     * 查询一级评论
     *
     * @return
     */
    public List<LevelOneComment> selectLevelOneComment(LevelOneComment levelOneComment);

    /**
     * 根据id删除一级评论
     *
     * @param id
     * @return
     */
    @Delete("DELETE FROM level_one_comment WHERE level_one_comment_id=#{id}")
    public boolean delectLevelOneComment(BigInteger id);

    /**
     * 根据id查看关联的人的id
     * @param id
     * @return
     */
    @Select("SELECT link_user_id from level_one_comment WHERE level_one_comment_id=#{id}")
    public Integer seleOneCommentLinkManById(Integer id);
}
